package yja.gzw.app.fragmentview

import android.content.Intent
import android.util.Log
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.TuijianAdapter
import yja.gzw.app.base.BaseFragment
import yja.gzw.app.databinding.FragmentGuanzhuBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.model.bean.QueryItem
import yja.gzw.app.viewmodel.Mainviewmodel

class GuanzhuFragment :BaseFragment<Mainviewmodel, FragmentGuanzhuBinding>(R.layout.fragment_guanzhu), TuijianAdapter.OnItemClickListener{
    private lateinit var listadapter2: TuijianAdapter
    private var shuju= mutableListOf<String>("1","2","3","4","1","2","3")
    override fun initView() {
        viewmodel.onguanzhuwang(UserData.token,mapOf("page" to "1"))





    }

    override fun dataObservese() {

        viewmodel.onguanzhu.observe(this, Observer{
            if(it.code==1){
                Toast.makeText(context,it.msg, Toast.LENGTH_SHORT).show()
                binding.liebiao.layoutManager=
                    LinearLayoutManager(context, LinearLayoutManager.VERTICAL,false)
                listadapter2= TuijianAdapter(requireContext(),it.data.data,this)
                binding.liebiao.adapter= listadapter2

                Log.e("关注数据","展示")


            }else{
                Toast.makeText(context,it.msg, Toast.LENGTH_SHORT).show()


            }


        })
    }

    override fun onItemClick(position: Int, uri: QueryItem) {

    }

}